/**
 * 主入口文件
 */
const express = require('express')
const app = new express()
const db = require('./src/dao/db') //连接数据库
const morgan = require('morgan'); // 日志


const Auth = require('./src/middles/Auth') // 权限校验
const router = require('./src/routers/index') // 路由
// const socket = require('./src/middles/socket') // websocket

const cors = require('cors'); // 跨域中间件
app.use(cors())
app.use(express.urlencoded({ extended: false }))
app.use(express.json())

app.use(morgan('dev'))


app.use(Auth)
app.use('/api', router);

app.listen(3000, () => {
    console.log('启动成功');
});

// app.listen(3001, () => {
//     console.log('启动成功');
// });